/*
 * @Author: Suo-Yuheng syh15399227325@163.com
 * @Date: 2025-09-02 20:48:08
 * @LastEditors: Suo-Yuheng syh15399227325@163.com
 * @LastEditTime: 2025-09-02 22:28:43
 * @FilePath: /0902/ThreadPool/main.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>
#include "ThreadPool.hpp"
#include "task.hpp"
#include <ctime>

int main()
{
    ThreadPool<Task> *tp = new ThreadPool<Task>(5);
    tp->Start();
    srand(time(nullptr) ^ getpid());

    while (true)
    {
        // 1、构建任务
        int x = rand() % 10 + 1;
        int y = rand() % 5;
        char op = opers[rand()%opers.size()];
        Task t(x, y, op);
        sleep(1);

        // 2、交给线程池处理
        cout << "main thread make a task: " << t.GetTask() << endl;
        tp->Push(t);
    }

    return 0;
}